<?php

/**
 * controler para stock
 *
 * @author jreyes
 */

require 'class/im/mov/DP/ImStockDP.class.php';
require 'class/im/mov/FN/ImStockFN.class.php';
//require 'class/frm/StockFrm.php';

class StockController extends ControllerBase
{
	/*	
    public function listarStock(){
        $StockBnController = new StockBnController();       
        $StockFilter       = $StockBnController->doStockBn();
        if ($this->requestVars){
            if (array_key_exists('articuloId', $this->requestVars)) {
                $StockFilter->articuloId     = $this->requestVars["articuloId"];
            }
            if (array_key_exists('almacenId', $this->requestVars)) {
                $StockFilter->almacenId      = $this->requestVars["almacenId"];
            }
        }
        $result = $StockBnController->listarStock($StockFilter);
        $vars['result']     = $result;
        $vars['articuloId'] = $this->requestVars["articuloId"];
        $vars['almacenId']  = $this->requestVars["almacenId"];
        $this->view->show("StockLista",$vars);
    }
	*/
	
    public function listarStock(){
		
        $o_ImStockFN= new ImStockFN();       

        $page = isset($this->requestVars['page']) ? $this->requestVars['page'] : 1;
        $rp = isset($this->requestVars['rp']) ? $this->requestVars['rp'] : 10;
        $sortname = isset($this->requestVars['sortname']) ? $this->requestVars['sortname'] : 'name';
        $sortorder = isset($this->requestVars['sortorder']) ? $this->requestVars['sortorder'] : 'desc';		
        $o_ImStockFN->page = $page;
        $o_ImStockFN->tamPag = $rp;
        $o_ImStockFN->sortCampos = $sortname;
        $o_ImStockFN->sortType   = $sortorder;
        if ($this->requestVars){
            if (array_key_exists('almacenId', $this->requestVars)) {
                $o_ImStockFN->setAlmId($this->requestVars["almacenId"]) ;   
            }
            if (array_key_exists('articuloId', $this->requestVars)) {
                $o_ImStockFN->setArtId($this->requestVars["articuloId"]);  
            }            
            if (array_key_exists('articuloNombre', $this->requestVars)) {
                $o_ImStockFN->setItemDescripcion($this->requestVars["articuloNombre"]);  
            }             
        }
        $result = $o_ImStockFN->selectExtended();     
        $vars['result'] = $result;
        $vars['stockFN'] = $o_ImStockFN;
        if (array_key_exists('modoBusqueda', $this->requestVars)) {
            $vars['modoBusqueda'] = $this->requestVars["modoBusqueda"];
        }else{
            $vars['modoBusqueda'] = "";
        }
        $this->view->show("im/mov/StockLista",$vars);
        //$message = "msg test";
	//mail('jaimereyesa@hotmail.com', 'test', $message);
	}
    
   public function listarStock2Rep(){
		
        $o_ImStockFN= new ImStockFN();       

        $page = isset($this->requestVars['page']) ? $this->requestVars['page'] : 1;
        $rp = isset($this->requestVars['rp']) ? $this->requestVars['rp'] : 10;
        $sortname = isset($this->requestVars['sortname']) ? $this->requestVars['sortname'] : 'name';
        $sortorder = isset($this->requestVars['sortorder']) ? $this->requestVars['sortorder'] : 'desc';		
        $o_ImStockFN->page = $page;
        $o_ImStockFN->tamPag = $rp;
        $o_ImStockFN->sortCampos = $sortname;
        $o_ImStockFN->sortType   = $sortorder;
        if ($this->requestVars){
            if (array_key_exists('almacenId', $this->requestVars)) {
                $o_ImStockFN->setAlmId($this->requestVars["almacenId"]) ;   
            }
            if (array_key_exists('articuloId', $this->requestVars)) {
                $o_ImStockFN->setArtId($this->requestVars["articuloId"]);  
            }            
            if (array_key_exists('articuloNombre', $this->requestVars)) {
                $o_ImStockFN->setItemDescripcion($this->requestVars["articuloNombre"]);  
            }             
        }
        $result = $o_ImStockFN->selectExtended();     
        $vars['result'] = $result;
        $vars['stockFN'] = $o_ImStockFN;
        if (array_key_exists('modoBusqueda', $this->requestVars)) {
            $vars['modoBusqueda'] = $this->requestVars["modoBusqueda"];
        }else{
            $vars['modoBusqueda'] = "";
        }
        $this->view->show("im/mov/StockListaReporte",$vars);
        //$message = "msg test";
	//mail('jaimereyesa@hotmail.com', 'test', $message);
    }    
        
        
    public function listarStockForm(){
		if (!isset($vars)){
			$vars = '';
		}        
        $this->view->show("im/mov/StockListaForm",$vars);
    }    
    
    public function listarStockReporte(){
		if (!isset($vars)){
			$vars = '';
		}        
        $this->view->show("im/mov/StockListaReporte",$vars);
    }  
    
}
?>